var map;

var markers = new Array();

function createMap() {
	map = new google.maps.Map(document.getElementById("map"), {
		zoom : 5,
		mapTypeId : google.maps.MapTypeId.ROADMAP
	});
}

function centerMap(latitude, longitude) {
	map.setCenter(new google.maps.LatLng(latitude, longitude));
}

function addMarker(title, latitude, longitude, link) {
	var marker = new Array();
	marker['title'] = title;
	marker['latitude'] = latitude;
	marker['longitude'] = longitude;
	marker['link'] = link;
	markers.push(marker);	
}

function showMarkersInMap() {
	for (i = 0; i < markers.length; i++) {
		var marker = new google.maps.Marker({
			position : new google.maps.LatLng(markers[i]['latitude'],
					markers[i]['longitude']),
			map : map,
			title : markers[i]['title']
		});
		if (markers[i]['link']) {
			var infoWindow = new google.maps.InfoWindow({
				content : "<a href='" + markers[i]['link'] + "' alt='"
						+ markers[i]['title'] + "'>" + markers[i]['title']
						+ "</a>"
			});
			google.maps.event.addListener(marker, 'click', function() {
				infoWindow.open(map, marker);
			});
		}
	}
}